package any.exception;

import static java.lang.String.format;

public class NoSuchKeyException extends RuntimeException {

	private static final long serialVersionUID = 5294595653040283985L;

	private static final String DEFAULT_ERR_MSG = "Key '%s' does not exist.";
	
	private final String key;
	
	public NoSuchKeyException(String key) {
		this(key, format(DEFAULT_ERR_MSG, key));
	}

	public NoSuchKeyException(String key, String message) {
		super(message);
		assert (key != null);
		this.key = key;
	}

	public NoSuchKeyException(String key, Throwable cause) {
		this(key, format(DEFAULT_ERR_MSG, key), cause);
	}

	public NoSuchKeyException(String key, String message, Throwable cause) {
		super(message, cause);
		assert (key != null);
		this.key = key;
	}

	public String getKey() {
		return key;
	}
	
}
